package com.littcore.saap.core.event;

import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 
 * 用户操作类事件.
 * 
 * <pre><b>描述：</b>
 *    操作类事件基础对象
 * </pre>
 * 
 * <pre><b>修改记录：</b>
 *    
 * </pre>
 * 
 * @author <a href="mailto:littcai@hotmail.com">蔡源</a>
 * @since 2015年10月16日
 * @version 1.0
 */
public class BaseOpEvent {
	
	private int tenantId;

	/**
	 */
	private int opBy;

	/**
	 */
	private String opUserName;

	/**
	 */
	private Date opDatetime;
	
	
	/**
	 * 功能编号.
	 */
	private String funcCode;
	
	/**
	 * 模块编号
	 */
	private String moduleCode;	
	
	private int recordId;
	
	private Map<String,Object>  datas;
	
	/** 
	 * 是否记录日志.
	 * 
	 * 对于不需要记录操作日志的可以置为否
	 */
	private boolean enableOpLog = true;	
	
	/** 用户操作注释. */
	private String opComment;

	public BaseOpEvent() {
		super();
	}

	

	public BaseOpEvent(String moduleCode, String funcCode, int recordId, int opBy, Date opDatetime) {
		super();
		this.moduleCode = moduleCode;
		this.funcCode = funcCode;
		this.recordId = recordId;
		this.opBy = opBy;
		this.opDatetime = opDatetime;
		this.datas=new LinkedHashMap<String,Object>();
	}



	public BaseOpEvent(String moduleCode, String funcCode, int recordId, int opBy, Date opDatetime, int tenantId) {
		super();
		this.moduleCode = moduleCode;
		this.funcCode = funcCode;
		this.recordId = recordId;
		this.opBy = opBy;
		this.opDatetime = opDatetime;
		this.tenantId = tenantId;
		this.datas=new LinkedHashMap<String,Object>();
	}
	
	public void addData(String key, Object value)
	{
	  this.addData(key, value, true);
	}
	
	public void addData(String key, Object value, boolean overwrite)
  {
    if(this.datas==null)
      this.datas = new HashMap<String, Object>();
    if(!overwrite && this.datas.containsKey(key))
      throw new IllegalStateException("Key:"+key+" is exist.");
        
    this.datas.put(key, value);
  }

	public int getTenantId() {
    return tenantId;
  }

  public void setTenantId(int tenantId) {
    this.tenantId = tenantId;
  }


	public String getModuleCode() {
		return moduleCode;
	}

	public void setModuleCode(String moduleCode) {
		this.moduleCode = moduleCode;
	}


	public int getOpBy() {
		return opBy;
	}

	public void setOpBy(int opBy) {
		this.opBy = opBy;
	}

	public String getOpUserName() {
		return opUserName;
	}

	public void setOpUserName(String opUserName) {
		this.opUserName = opUserName;
	}

	public Date getOpDatetime() {
		return opDatetime;
	}

	public void setOpDatetime(Date opDatetime) {
		this.opDatetime = opDatetime;
	}

	public String getFuncCode() {
		return funcCode;
	}

	public void setFuncCode(String funcCode) {
		this.funcCode = funcCode;
	}

	public int getRecordId() {
		return recordId;
	}

	public void setRecordId(int recordId) {
		this.recordId = recordId;
	}



	public Map<String, Object> getDatas() {
		return datas;
	}
	
	public void setDatas(Map<String, Object> datas) {
		this.datas = datas;
	}
  
  /**
   * @return the enableOpLog
   */
  public boolean isEnableOpLog()
  {
    return enableOpLog;
  }



  
  /**
   * @param enableOpLog the enableOpLog to set
   */
  public void setEnableOpLog(boolean enableOpLog)
  {
    this.enableOpLog = enableOpLog;
  }



  
  /**
   * @return the opComment
   */
  public String getOpComment()
  {
    return opComment;
  }



  
  /**
   * @param opComment the opComment to set
   */
  public void setOpComment(String opComment)
  {
    this.opComment = opComment;
  }







	
	
	
	

}
